<template>
  <div class="carousel" :class="{cbg}">
    <input type="radio" name="slider" id="item-1" :checked="ckd1" @change="carbg">
    <input type="radio" name="slider" id="item-2" :checked="ckd2" @change="carbg">
    <input type="radio" name="slider" id="item-3" :checked="ckd3" @change="carbg">
   <div class="cards">
    <label class="card" for="item-1" id="song-1">
      <img src="../assets/house/car1.jpg" alt="song">
    </label>
    <label class="card" for="item-2" id="song-2">
      <img src="../assets/house/car2.jpg" alt="song">
    </label>
    <label class="card" for="item-3" id="song-3">
      <img src="../assets/house/car3.jpg" alt="song">
    </label>
    </div>
  </div>
</template>
<script>
export default {
  data(){
    return{
     cbg:false,
     ckd1:true,
     ckd2:false,
     ckd3:false
    }
  },
  methods:{
     carbg(){
       if(this.cbg==false){
         this.cbg=true;
       }else{
         this.cbg=false;
       }
     }
  },
  mounted(){
   let lb=setInterval(()=>{
      if(this.ckd1==true){
        this.ckd2=true;
        this.ckd1=false;
        this.carbg();
      }else if(this.ckd2==true){
        this.ckd3=true;
        this.ckd2=false;
        this.carbg();
      }else{
        this.ckd1=true;
        this.ckd3=false;
        this.carbg();
      }
    },4000);
  }
}
</script>

<style>
.cbg{
  background: rgba(49, 194, 124, 0.5);
}
.carousel input[type=radio] {
  display: none;
}

.carousel .card {
  position: absolute;
  height: 100%;
  left: 0;
  right: 0;
  margin: auto;
  -webkit-transition: -webkit-transform .4s ease;
  transition: -webkit-transform .4s ease;
  transition: transform .4s ease;
  transition: transform .4s ease, -webkit-transform .4s ease;
  cursor: pointer;
}
  
.carousel{
  padding-top: 10px;
  padding-bottom: 10px;
  width: 100%;
  max-height: 500px;
  height: 500px;
  -webkit-transform-style: preserve-3d;
          transform-style: preserve-3d;
  display: -webkit-box;
  display: flex;
  margin: auto;
  -webkit-box-pack: center;
          justify-content: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
          flex-direction: column;
  -webkit-box-align: center;
          align-items: center;
  -webkit-transition: -webkit-background .4s ease;
          transition: -webkit-background .4s ease;
          transition: background .4s ease;
          transition: background .4s ease, -webkit-background .4s ease;
}
.carousel .cards {
  position: relative;
  width: 800px;
  height: 100%;
}

.carousel img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  -o-object-fit: cover;
     object-fit: cover;
}

.carousel #item-1:checked ~ .cards #song-3, #item-2:checked ~ .cards #song-1, #item-3:checked ~ .cards #song-2 {
  -webkit-transform: translatex(-40%) scale(0.8);
          transform: translatex(-40%) scale(0.8);
  opacity: .4;
  z-index: 0;
}

.carousel #item-1:checked ~ .cards #song-2, #item-2:checked ~ .cards #song-3, #item-3:checked ~ .cards #song-1 {
  -webkit-transform: translatex(40%) scale(0.8);
          transform: translatex(40%) scale(0.8);
  opacity: .4;
  z-index: 0;
}

.carousel #item-1:checked ~ .cards #song-1, #item-2:checked ~ .cards #song-2, #item-3:checked ~ .cards #song-3 {
  -webkit-transform: translatex(0) scale(1);
          transform: translatex(0) scale(1);
  opacity: 1;
  z-index: 1;
}
.carousel #item-1:checked ~ .cards #song-1 img, #item-2:checked ~ .cards #song-2 img, #item-3:checked ~ .cards #song-3 img {
  box-shadow: 0px 0px 5px 0px rgba(81, 81, 81, 0.47);
}
</style>
